﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;

namespace ExtensionMethods
{
    public static class MyExtensions
    {
        public static Point Center(this Rectangle rec)
        {
            return new Point(rec.Left + rec.Width / 2, rec.Top + rec.Height / 2);
        }

        public static ushort toUShort(this bool[] tb)
        {
            ushort value = 0;

            for (int i = 0; i < tb.Length; i++)
            {
                if (tb[i])
                    value += (ushort) Convert.ToInt16(Math.Pow(2, i));
            }

            return value;
        }



    }

}